<?php
/**
 * CreateTime: 2023/11/27 16:55
 * User:LinQ
 */

namespace App\Http\Requests\Department;

use App\Http\Requests\BasicFormRequests;

class DepartmentRequest extends BasicFormRequests
{
    protected $rule =[
        'department_name' => 'required',
        'responsible_user_id' => 'required|user_id_has',
        'pid' => 'dept_id_has'
    ];

    public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
    {
        $this->message = [
            'department_name.required'=>trans('message.request_required',[
                'name' => trans('key.department')
            ]),
            'responsible_user_id.required'=>trans('message.request_required',[
                'name' => trans('key.responsible_user')
            ]),
            'responsible_user_id.user_id_has'=>trans('message.not_exists',[
                'name' => trans('key.responsible_user')
            ]),
            'pid.dept_id_has' =>trans('message.not_exists',[
                'name' => trans('key.superior_department')
            ]),
        ];

        parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content);
    }


    protected $scene = [
        'create' => ['department_name','responsible_user_id','pid'],
        'update' => ['responsible_user_id|user_id_has','pid']
    ];
}